<?php
if(isset($_POST['submit']) && $_POST['submit']=='Masuk') {
	require_once "konfigurasi.php";

	fungsi('login');

	$user	= $_POST['username'];
	$pass	= md5(strtolower($_POST['password']));

	koneksi_buka();
	$login	= mysql_query("SELECT * FROM t_pengguna WHERE username='$user' AND password='$pass'");
	$found	= mysql_num_rows($login);
	$r		= mysql_fetch_array($login);

	if ($found > 0) {
		catat_log($r['kd_pengguna'],'in');

		session_start();
		$info 						= info_pegawai($r['kd_pengguna']);
		$_SESSION['kd_pengguna']	= $r['kd_pengguna'];
		$_SESSION['jns_pengguna']	= $r['jns_pengguna'];
		$_SESSION['kd_pegawai']		= $info[0];
		$_SESSION['nm_pengguna']	= $info[1];
		$_SESSION['kd_jabatan']		= $info[2];
		$_SESSION['nm_jabatan']		= $info[3];
		$_SESSION['username']		= $info[4];		
		$_SESSION['sesi_login']		= true;

		koneksi_tutup();
		loncat("beranda.php");
	} else {
		loncat("index.php?m=salah");
	}
} else {
	header('location:index.php');
}
?>
